package org.kjtc.controller;

import org.kjtc.entity.UserInfo;
import org.kjtc.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * Created by Administrator on 2017/11/15 0015.
 */
@Controller
public class IndexController extends BaseController {

    @Autowired
    private LoginService loginService;

    @RequestMapping("")
    public String toLogin(String userID){
        System.out.println("userID>>>" + userID);
        if (userID != null && !userID.isEmpty()){
            List<UserInfo> list = loginService.toIndex(userID);
            this.getSession().setAttribute("userInfo", list.get(0));
            return "index";
        } else {
            return "login";
        }
    }

    @RequestMapping("/login")
    public String toRedirect(String userID){
        System.out.println("userID>>>" + userID);
        if (userID != null && !userID.isEmpty()){
            List<UserInfo> list = loginService.toIndex(userID);
            this.getSession().setAttribute("userInfo", list.get(0));
            return "index";
        } else {
            return "login";
        }
    }

    @RequestMapping("/signOut")
    public String toSignOut(){
        this.getSession().invalidate();
        return "/login";
    }

    @RequestMapping(value="/promptMessage")
    public String toPromptMessage(){
        return "promptMessage";
    }

    @RequestMapping(value="/operationLog")
    public String toOperationLog(){
        return "operationLog";
    }

    @RequestMapping(value="/index")
    public String toIndex(){
        return "index";
    }

    @RequestMapping(value="/backLog")
    public String toBackLog(){
        return  "backLog";
    }

    @RequestMapping(value="/product")

    public String toProduct(){
        return  "product";
    }

    @RequestMapping(value="/reportForm")
    public String toReportform(){
        return  "reportForm";
    }

    @RequestMapping(value="/feedback")
    public String toFeedback(){
        return  "feedback";
    }

    @RequestMapping(value="/user")
    public String toProjectManage(){
        return  "user";
    }

    @RequestMapping(value="/sprint")
    public String toSprint(){
        return  "sprint";
    }

    @RequestMapping(value="/setUp")
    public String toSetUp(){
        return  "setUp";
    }


}
